#include <stdio.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

char *inode_to_name(int inode);
void ppath();

int main(int argc,char *argv[])
{
 ppath(); 
}

char *inode_to_name(int inode)  
{  
    char *str;  
    DIR *dirp;  
    struct dirent *dirt;  
    if((dirp = opendir(".")) == NULL){  
        perror(".");  
        exit(-1);  
    }  
    while((dirt = readdir(dirp)) != NULL)  
    {  
        if(dirt->d_ino == inode){  
            str = (char *)malloc(strlen(dirt->d_name)*sizeof(char));  
            strcpy(str,dirt->d_name);  
            return str;  
        }  
    }  
    perror(".");  
    exit(-1);  
}  

void ppath(){
  char* str;  

  struct stat p,p1; 
  if(stat(".",&p) == -1){  
     perror(str);  
     exit(-1);  
  } 
 
  if(stat("..",&p1) == -1){  
     perror(str);  
     exit(-1);  
  }

  chdir("..");
  str = inode_to_name(p.st_ino);

  if(p.st_ino == p1.st_ino)
  {
    return;
  }
  
  ppath();

  printf("/%s",str);

}
